package com.blockmeta.bbs.businesslibrary.umeng.dialog;

import android.app.Activity;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.blockmeta.bbs.businesslibrary.R;
import com.blockmeta.bbs.businesslibrary.umeng.AnimatorUtil;
import com.blockmeta.bbs.businesslibrary.umeng.BaseShareDialog;
import com.blockmeta.bbs.businesslibrary.umeng.MEDIA_TYPE;
import com.blockmeta.bbs.businesslibrary.umeng.ShareRouter;
import com.blockmeta.bbs.businesslibrary.umeng.SharedUtils;

/**
 * @author AirThor
 * @date 2020/3/23.
 * 一般网页形式的分享
 */
public class NormalWebShare extends BaseShareDialog {
    public NormalWebShare(Context context, ShareRouter shareRouter) {
        super(context, shareRouter);
    }

    @Override
    protected void initContent() {
        ImageView imCircle = find(R.id.iv_im_circle);
        View imCircleTv = find(R.id.tv_im_circle);
        ImageView wechat = find(R.id.iv_wechat);
        View wechatTv = find(R.id.tv_wechat);
        ImageView ciecle = find(R.id.iv_wechat_circle);
        View circleTv= find(R.id.tv_wechat_circle);
        ImageView qq = find(R.id.iv_qq);
        View qqTv = find(R.id.tv_qq);
        ImageView weibo = find(R.id.iv_weibo);
        View weiboTv=find(R.id.tv_weibo);
        TextView cancel = find(R.id.tv_cancel);

        View board = find(R.id.csl_out_area);
        AnimatorUtil.bottomToTopAnim(board,500,false,0.8f);

        AnimatorUtil.bottomToTopAnim(imCircle,2400);
        AnimatorUtil.bottomToTopAnim(imCircleTv,2400);
        AnimatorUtil.bottomToTopAnim(wechat,2000);
        AnimatorUtil.bottomToTopAnim(wechatTv,2000);
        AnimatorUtil.bottomToTopAnim(ciecle,1600);
        AnimatorUtil.bottomToTopAnim(circleTv,1600);
        AnimatorUtil.bottomToTopAnim(weibo,1200);
        AnimatorUtil.bottomToTopAnim(weiboTv,1200);
        AnimatorUtil.bottomToTopAnim(qq,800);
        AnimatorUtil.bottomToTopAnim(qqTv,800);

        wechat.setOnClickListener(this);
        ciecle.setOnClickListener(this);
        qq.setOnClickListener(this);
        weibo.setOnClickListener(this);
        imCircle.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }

    @Override
    protected int setContentViews() {
        return R.layout.view_share_board;
    }

    @Override
    protected void setAttributes() {
        setAttribute(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
    }

    @Override
    protected void startShare(MEDIA_TYPE mediaType) {
        if (mediaType == MEDIA_TYPE.IM){
            SharedUtils.shareIMWeb((Activity) mShareRouter.getContext(),mShareRouter.getUrl(), mShareRouter.getThumb(), mShareRouter.getTitle(), mShareRouter.getDesc(),mShareRouter.getTypeDescribe());
        }else {
            SharedUtils.shareWeb((Activity) mShareRouter.getContext(), mediaType.mMedia, mShareRouter.getUrl(),
                    mShareRouter.getThumb(), mShareRouter.getTitle(), mShareRouter.getDesc(),mShareRouter.getUMShareListener());
        }

        safeDismiss();
    }
}
